package models

import (
	"github.com/astaxie/beego/orm"
	"fmt"
)

//报名表
type Entry struct {
	Id              int64
	EntryNo         string
	EntryName       string
	EntryTel        string
	EntryCount      string
	EntryActivity   string
	EntryTime       string
	Status          string

}
//建立模型
func init() {
	orm.RegisterModel(new(Entry))
}

//获取活动列表
func GetEntrylist(page int64, page_size int64, sort string) (entry []orm.Params, count int64) {
	o := orm.NewOrm()
	Entry := new(Entry)
	qs := o.QueryTable(Entry).Filter("Status", "0")
	var offset int64
	if page <= 1 {
		offset = 0
	} else {
		offset = (page - 1) * page_size
	}
	qs.Limit(page_size, offset).OrderBy(sort).Values(&entry)
	count, _ = qs.Count()
	fmt.Println("entry:", entry)
	fmt.Println("count:", count)
	return entry, count
}